;;; Copyright (c) 1999 Massachusetts Institute of Technology
;;;
;;; This program is free software; you can redistribute it and/or
;;; modify it under the terms of the GNU General Public License as
;;; published by the Free Software Foundation; either version 3 of the
;;; License, or (at your option) any later version.
;;;
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
;;; General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with this program; if not, see https://gnu.org/licenses or
;;; write to:
;;;  Free Software Foundatiom, Inc.
;;;  51 Franklin St, Fifth Floor
;;;  Boston, MA 02110-1301
;;;  USA

;;; Chaosnet interface on Unibus

CAICSR=3,,764140  ;COMMAND STATUS REG
CH%CSR==0
 %CABSY==1	  ;0 XMT BUSY (RO)
 %CALUP==2	  ;1 LOOP BACK (R/W)
 %CASPY==4	  ;2 RECIEVE MSGS FOR ANY DESTINATION (R/W)
 %CARCL==10	  ;3 CLEAR THE RECEIVER, IT CAN NOW GOBBLE ANOTHER MSG (WO)
 %CAREN==20	  ;4 RCV INT ENB (R/W)
 %CATEN==40	  ;5 XMT INT ENB (R/W)
 %CATAB==100	  ;6 TRANSMIT ABORTED BY ETHER CONFLICT (RO)
 %CATDN==200	  ;7 TRANSMIT DONE. SET WHEN TRANSMITTER IS DONE
 %CATCL==400	  ;8 CLEAR THE TRANSMITTER, MAKING IT READY (WO)
 $CALOS==110400	  ;9-12    LOST COUNT (RO) [# MSGS RCVED WITH RCV BFR FULL]
		  ;        WHEN MSG IS WAITING IN BUFFER, THIS COUNTS
		  ;        THE MESSAGES THAT MATCHED OUR DESTINATION OR
		  ;        WERE BROADCAST, BUT COULDN'T BE RECIEVED.
		  ;	 WHEN RECEIVER IS RE-ENABLED (WRITE 1 INTO %CARDN)
		  ;	 THE COUNT IS THEN CLEARED.
		  ;	 WHEN A MESSAGE IS LOST, RECEIVER ZAPS ETHER
		  ;	 SO TRANSMITTER WILL ABORT (IF MESSAGE WAS DESTINED
		  ;        TO US.)
 %CARST==20000	  ;13 I/O RESET (WO)
 %CAERR==40000	  ;14 CRC ERROR (RO)
 %CARDN==100000	  ;15  RCV DONE.  

CAIMYN==3,,764142 ;MY # (READ ONLY)
CH%MYN==2	  ;RETURNS THE [SOURCE] HOST# OF THIS INTERFACE.		

CAIWBF=3,,764142  ;WRITE BUFFER (WRITE ONLY)
CH%WBF==2	  ;FIRST WAIT FOR TDONE. (OR SET IT VIA CSR)
		  ;FIRST WORD IN RESETS TRANSMITTER AND CLEARS TDONE.
		  ;STORE INTO THIS REGISTER TO WRITE WORDS OF MESSAGE,
		  ;LAST WORD IN IS DESTINATION ADDRESS, THEN READ CAIXMT.
		  ;SOURCE ADDRESS AND CHECK WORD PUT IN BY HARDWARE.

CAIRBF=3,,764144  ;READ BUFFER (READ ONLY)
CH%RBF==4	  ;THE FIRST WORD READ WILL BE FILLED TO THE LEFT
		  ;TO MAKE THE MESSAGE RECIEVED A MULTIPLE OF 16 BITS.
		  ;IF THE NUMBER OF DATA BITS IN THE MESSAGE WAS A
		  ;MULTIPLE OF 16, THIS WORD WILL BE THE FIRST WORD PUT
		  ;INTO THE BUFFER BY THE TRANSMITTING HOST.
		  ;THE LAST 3 WORDS READ ARE DESTINATION, SOURCE, CHECK.

CAIRBC=3,,764146  ;RECEIVE BIT COUNTER  (READ ONLY)
CH%RBC==6	  ;WHEN A MESSAGE HAS BEEN RECEIVED THIS IS ONE LESS THAN
		  ;THE NUMBER OF BITS IN THE MESSAGE (16 X THE
		  ;NUMBER OF WORDS INCLUDING THE THREE OVERHEAD WORDS.)
		  ;AFTER THE LAST WORD (THE CRC WORD) HAS BEEN READ, IT IS 7777
		  ;BITS 10 AND 11 ARE THE HIGH ORDER BITS, AND IF THEY ARE ONE,
		  ;THEN THERE WAS A BUFFER OVERFLOW

CAIXMT=3,,764152  ;READING THIS INITIATES TRANSMISSION (!!)
CH%XMT==12	  ;THE VALUE READ IS ONE'S OWN HOST#.

;REFERENCING ADDRESSES IN THE GROUP OF 8 WORDS NOT LISTED HERE, OR
;USING COMBINATIONS OF READ/WRITE NOT LISTED HERE, WILL TYPICALLY CAUSE
;STRANGE AND BIZARRE EFFECTS.
